package idv.cjcat.pyronova.nodes {
	import flash.geom.Matrix;
	import flash.geom.Point;
	import idv.cjcat.pyronova.render.RenderVisitor;
	import idv.cjcat.pyronova.utils.GraphicsUtils;
	
	public class Circle extends Node {
		
		public var x:Number;
		public var y:Number;
		public var radius:Number;
		public var color:uint;
		public var useAlpha:Boolean;
		
		public function Circle(x:Number = 0, y:Number = 0, radius:Number = 10, color:uint = 0xFF000000, useAlpha:Boolean = false) {
			this.x = x;
			this.y = y;
			this.radius = radius;
			this.color = color;
			this.useAlpha = useAlpha;
		}
		
		private var p:Point = new Point();
		private var m:Matrix;
		override public function render(visitor:RenderVisitor):void {
			visitor.pushMatrix(matrix());
			m = visitor.topMatrix();
			p.x = radius;
			p.y = 0;
			radius = m.deltaTransformPoint(p).length;
			p.x = x;
			p.y = y;
			p = m.transformPoint(p);
			visitor.popMatrix();
			GraphicsUtils.drawCircle(p.x, p.y, radius, color, useAlpha, visitor.graphics().topBuffer());
		}
	}
}